document.getElementById('openSidebar').addEventListener('click', async () => {
  try {
    // 获取当前窗口
    const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
    const windowId = tab.windowId;
    
    // 打开侧边栏
    await chrome.sidePanel.open({ windowId: windowId });
    console.log('Sidebar opened successfully');
  } catch (error) {
    console.error('Error opening sidebar:', error);
  }
}); 